
use "$data/clean/clean_main_complete.dta" , replace


tempfile main
save `main', replace

clear all
eststo clear
estimates drop _all

loc columns = 6

set obs 10
gen x = 1
gen y = 1

forval i = 1/`columns' {
	eststo col`i': reg x y
} 

loc count = 1

loc statnames ""
loc varlabels ""

/* Custom fill cells */



use `main', clear



gen pana=.
gen panb=.
gen panc=.
gen pand=.
gen pane=.
gen intt= .
gen empt =. 
gen part_aff = .

label var pana "\underline{Individual level characteristics} " 
label var panb "\underline{Prior experience} " 

label var empt " "
  
  foreach yvar of varlist pana  female age party_member member_years voice_prior   z_votes_own z_votes_other_1 z_votes_other_2 ///
 empt panb d_experience_campaign pre_doortodoor pre_days_doortodoor pre_posters pre_booth pre_online pre_call pre_friends pre_others  empt  {
	qui sum `yvar', d
	if `r(N)'!=0 {
	qui sum `yvar' if  control ==1
	cap: estadd loc thisstat`count' = string(`r(mean)', "%9.2f"): col1
	
	qui sum `yvar' if  feedback_pooled == 1
	cap: estadd loc thisstat`count' = string(`r(mean)', "%9.2f"): col2
	
		qui sum `yvar' if no_feedback_pooled == 1
	cap: estadd loc thisstat`count' = string(`r(mean)', "%9.2f"): col3
	
	
	reg `yvar'  no_feedback_pooled feedback_pooled, r

	
	test feedback_pooled
	cap: estadd loc thisstat`count' = string(`r(p)', "%9.2f"): col4
	
	
	test no_feedback_pooled
	cap: estadd loc thisstat`count' = string(`r(p)', "%9.2f"): col5

	test  no_feedback_pooled = feedback_pooled
	cap: estadd loc thisstat`count' = string(`r(p)', "%9.2f"): col6


	}

	/* Row Labels */
	
	loc thisvarlabel: variable label `yvar'
	local varlabels "`varlabels' "`thisvarlabel'" "
	loc statnames "`statnames' thisstat`count'"
	loc count = `count' + 1
}

  

/* Footnotes */

loc prehead "\begin{tabular}{l*{`columns'}{c}} \toprule"

loc postfoot "\bottomrule \end{tabular}"

esttab col* using "$output/balance_pooled_feedback", booktabs cells(none) nogap mtitle("Control" "Feedback" "No feedback"  "p(Feed=Cont)"  "p(No Feed=Cont)"  "p(Feed=No Feed)" ) ///
 stats(`statnames', labels(`varlabels'))  prehead("`prehead'") postfoot("`postfoot'") compress wrap replace

eststo clear


